Namespace - LJCDBClientLib
Syntax
C# |
public class ObjectManager<TData, TList>
|
Provides object specific data methods.
(RE)
Remarks
The Object Manager is a generic class that is used by a client application
to interface with the contained
DataManager
object.
The Object Manager converts the Result XML message data into client Data
objects. The Data object property names must match those in the Data
Definition.
The Add(),
Delete(),
Load(),
Retrieve() and
Update()
methods take a client Data object as a parameter. They access properties
in the Data object using reflection.
The CreateCollection() and
CreateData()
methods use reflection to populate client Data objects with the result
data.
The test code is found in project LJCDBClientLib\TestObjectManager and
LJCDataManagerTest.
Public Methods
18 Methods
Properties
Example
C# |
IF NOT EXISTS(SELECT* FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = N'PersonTest')
BEGIN
CREATE TABLE[dbo].[PersonTest]
(
[Id][int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar] (60) NULL,
[PrincipleFlag] [bit] NOT NULL,
CONSTRAINT[PK_PersonTest]
PRIMARY KEY CLUSTERED(
[Id] ASC),
)
END
GO
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using LJCDBClientLib;
using LJCDBMessage;
using LJCDBDataAccessLib;
using LJCDBServiceLib;
public class Person
{
public Int32 ID { get; set; }
public string Name { get; set; }
public bool PrincipleFlag { get; set; }
}
public class Persons : List<Person> { }
public static void TestObjectDataAccess()
{
DbConnectionStringBuilder connectionBuilder;
DbDataAccess dbDataAccess;
string databaseName = "DatabaseName";
connectionBuilder = new DbConnectionStringBuilder()
{
{ "Data Source", "DataServiceName" },
{ "Initial Catalog", databaseName },
{ "Integrated Security", "True" }
};
string connectionString = connectionBuilder.ConnectionString;
string providerName = "System.Data.SqlClient";
dbDataAccess = new DbDataAccess(connectionString, providerName
, databaseName);
DbServiceRef dbServiceRef = new DbServiceRef()
{
DbDataAccess = dbDataAccess,
};
ObjectManager<Person, Persons> personManager;
personManager = new ObjectManager<Person, Persons>(dbServiceRef, null
, "PersonTest");
if (personManager.IsSuccess)
{
personManager.MapNames("Id", "ID");
personManager.DbAssignedColumnNames = new string[]
{
"Id"
};
personManager.LookupColumnNames = new string[]
{
"Id",
"Name"
};
Persons persons = Load(personManager);
Add(personManager);
Person person = Retrieve(personManager);
persons = Load(personManager);
Update(personManager);
persons = Load(personManager);
Delete(personManager);
persons = Load(personManager);
Add(personManager);
person = RetrieveClientSql(personManager);
persons = LoadClientSql(personManager);
ExecuteClientSql(personManager);
persons = LoadClientSql(personManager);
}
}
|
Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.